from common.models import Stage, Module
from task_manage_sys.serializers import DynamicFieldModelSerializer
from rest_framework import serializers


class StageSerializer(DynamicFieldModelSerializer):
    class Meta:
        model = Stage
        fields = '__all__'


class ModuleSerializer(DynamicFieldModelSerializer):
    stage_name = serializers.ReadOnlyField(source='stage.name')

    class Meta:
        model = Module
        fields = '__all__'


class StageModuleSerializer(DynamicFieldModelSerializer):
    modules = ModuleSerializer(many=True, read_only=True, fields=["id", "name"])

    class Meta:
        model = Stage
        fields = '__all__'
